﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<nsadv.Statistic.Web.ViewModels.BannerPeriodicalDetailsModel>" %>
<%@ Import Namespace="nsadv.Statistic.Web.RenderHelpers" %>
<%
	int maxShowCount = Model.BannerRows.Count() > 0 ? (from item in Model.BannerRows select item.ShowCount).Max() : 0;
	int maxClickCount =  Model.BannerRows.Count() > 0 ? (from item in Model.BannerRows select item.ClickCount).Max() : 0;
%>
<table class="bannerstbl" cellpadding="0" cellspacing="0">
	<thead>
		<tr>
			<td style="width: 75px;">
				Дата
			</td>
			<td>
				Показы / Расхлопы / Клики / Уники / CTR
			</td>
			<td style="width: 25%;">
				График показов
			</td>
			<td style="width: 25%;">
				График кликов
			</td>
		</tr>
	</thead>
	<tbody>
		<% foreach (var statInfo in Model.BannerRows)
     {%>
		<tr>
			<td>
				<%--<%: string.Format("{0}.{1}.{2}", statInfo.Day, statInfo.Month, statInfo.Year)%>--%>
				<%: Html.GroupingDate(Model.Groupping, statInfo) %>
			</td>
			<td style="text-align: center;">
				<%: statInfo.ShowCount %> /	
				<%: statInfo.ExpandCount %> / 
				<%: statInfo.ClickCount%> / 
				<%: statInfo.UniqueClickCount %> /
				<span class="red"><%: (statInfo.ShowCount > 0 ? statInfo.ClickCount / (double)statInfo.ShowCount : 0).ToString("P") %></span>
			</td>
			<td>
				<div style="background-color: red; width: <%: Math.Round(statInfo.ShowCount / (double)maxShowCount * 100) %>%;
					height: 5px;">
					&nbsp;</div>
			</td>
			<td>
				<div style="background-color: blue; width: <%: maxShowCount > 0 ? Math.Round(statInfo.ClickCount / (double)maxShowCount * 100) : 0 %>%;
					height: 5px; margin: 0px 4px;">
					&nbsp;</div>
			</td>
		</tr>
		<%
     }%>
	</tbody>
</table>

<table>
	<tbody>
		<tr>
			<td valign="middle">
				<div style="width: 20px; height: 8px; background-color: rgb(255, 0, 0);">
					&nbsp;</div>
			</td>
			<td valign="middle">
				Количество показов (max <span id="spMaxShows"><%: maxShowCount%></span>)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</td>
			<td valign="middle">
				<div style="width: 20px; height: 8px; background-color: rgb(0, 0, 255);">
					&nbsp;</div>
			</td>
			<td valign="middle">
				Количество кликов (max <span id="spMaxClicks"><%: maxClickCount%></span>)
			</td>
		</tr>
	</tbody>
</table>
